﻿using SMALLERP.DataClass;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace XJLSC.INV
{
    public partial class KWGL : Form
    {
        DataBase db = new DataBase();
        public KWGL()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
              String strSql = null;
              strSql = "";
               try
               {
                    DataTable dt;
                    strSql = "SELECT ITEM_CODE 品号,ITEM_NAME 品名,ITEM_SPECIFICATION 规格,UDF021 库位 FROM ITEM WHERE (ITEM_CODE LIKE '%" + textBox1.Text + "%' OR ITEM_NAME LIKE '%" + textBox1.Text + "%' OR ITEM_SPECIFICATION LIKE '%" + textBox1.Text + "%') AND UDF021 LIKE '%" + textBox2.Text + "%'";
                    this.gridControl1.Refresh();

                    dt = db.GetDataSet1(strSql, "MOCTA").Tables["MOCTA"];
                    //dt.Rows.Add();
                    this.gridControl1.DataSource = dt;
                    gridView1.OptionsView.EnableAppearanceEvenRow = true;
                    gridView1.OptionsView.EnableAppearanceOddRow = false;
               }
                catch (Exception ex)
               {
                MessageBox.Show(ex.Message, "软件提示");
                //throw ex;
               }
        }

        private void button2_Click(object sender, EventArgs e)
        {

            int[] rows = this.gridView1.GetSelectedRows();
            foreach (int row in rows)
            {
                String clph = this.gridView1.GetRowCellValue(row, "品号").ToString();
                String clpm = this.gridView1.GetRowCellValue(row, "品名").ToString();
                String clgg = this.gridView1.GetRowCellValue(row, "规格").ToString();
                String clkw = this.gridView1.GetRowCellValue(row, "库位").ToString();

                string strSql1 = "UPDATE ITEM SET UDF021='" + clkw + "' WHERE ITEM_CODE='" + clph + "'";
                try
                {
                    if (db.ExecDataBySql1(strSql1) > 0)
                    {
                    }
                    else
                    {
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "软件提示");
                    throw ex;
                }
            }
            MessageBox.Show("更新成功！","系统提示");
        }
    }
}
